<?php

/**
* ExceptionHandlerTest.php
*
* Test user exception handler
*
* @author     Blazej Zieba <b@zieba.info>
* @copyright  2007 konekto.com
* @version    CVS: $Id:$
*/
require_once '../config.php';

require_once 'simpletest/autorun.php';

require_once '../PageFactory.php';

class PageFactoryTest extends  UnitTestCase
{
    protected $defaultPage;

    public function setUp()
    {
        $this->defaultPage = "PageExample";
        unset($_GET['cmd']);
    }

    public function testLackOfDefaultPageAndCmdNotSet()
    {
        $this->expectError('ENTER getPage()');
        $this->expectError('Default command not set');
        getPage();
    }

    public function testDefaultPageExistAndCmdNotSet()
    {
        $this->expectError('ENTER getPage()');
        $this->expectError('Use default command: '.$this->defaultPage);
        $this->expectError('LEAVE getPage()');
        $this->assertEqual($this->defaultPage, get_class(getPage($this->defaultPage)));
    }
    

    public function testCmdExist()
    {
        $this->expectError('ENTER getPage()');
        $_GET['cmd'] = $this->defaultPage;
        $this->expectError('LEAVE getPage()');
        $this->assertEqual($this->defaultPage, get_class(getPage()));
    }
    public function tearDown()
    {

    }
}

?>
